
const getWidth = (el) => {
    let {height} = el.getBoundingClientRect();
    return height
};

export default {
    binding(el, binding, vnode) {
        console.log('binding');
    },

    inserted(el, binding, vnode) {},

    update(el, binding, vnode, oldVnode) {
        console.log('update')
    },

    componentUpdated(el, binding, vnode, oldVnode) {
        console.log('componentUpdated')
        setTimeout(()=>{
            const content1 = el.children[0];
            const content2 = el.children[1];
            let elementHeight = el&&getWidth(el);
            let childrenHeight1 = el&&getWidth(content1);
            let childrenHeight2 = el&&getWidth(content2);
            const childrenH = Math.max(childrenHeight1, childrenHeight2);
            console.log(`父元素:${elementHeight}`)
            console.log(`子元素:${childrenH}`)
            if (childrenH >= elementHeight) {
                content1.style.display = 'block';
                content1.style.visibility = 'visible';
                content2.style.display = 'none'
            } else {
                content1.style.display = 'none';
                content1.style.visibility = 'hiddle';
                content2.style.display = 'block'
            }
        },1000)
    },

    unbind(el, binding, vnode) {
        console.log('unbind');
    }

}